package com.ssm_basic.egnotice1.base.response;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Setter
@Getter
@AllArgsConstructor
@NoArgsConstructor
public class JsonResult {
    private Integer code;
    private String msg;
    private Object data;

    public JsonResult(CodeMsg codeMsg) {
        this.code = codeMsg.getCode();
        this.msg = codeMsg.getMsg();
    }
    public JsonResult(CodeMsg codeMsg, Object data) {
        this.code = codeMsg.getCode();
        this.msg = codeMsg.getMsg();
        this.data = data;
    }

    public static JsonResult success(Object data) {
        return new JsonResult(CodeMsg.OPERATION_SUCCESS, data);
    }
    public static JsonResult success() {
        return success(null);
    }
}
